package com.zkj.sentinel.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName: DemoController
 * @Description: TODO
 * @Author: Zhukj
 * @Date: 2021-11-4 11:39
 */
@RestController
public class DemoController {

    @GetMapping("/test1")
    public String test1(){
        return "0----test1";
    }

    /**
     * 阻塞后自定义处理
     * 有时候跳到自带的处理 有时候会到自定义的处理
     * @return
     */
    @SentinelResource(value = "/test2", fallback = "handleBlock")
    @GetMapping("/test2")
    public String test2(){
        return "0----test2";
    }

    @GetMapping("/test3")
    public String test3(){
        int age= 10/0;
        return "0----test3";
    }


    @GetMapping("/test4")
    public String test4(){
        System.out.println("测试啊 test4");
        return "0----test4";
    }



    public String handleBlock(){
        return "进入阻塞";
    }

}
